package com.wj.blog.controller;
import com.wj.blog.pojo.About;
import com.wj.blog.service.AboutService;
import com.wj.blog.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Author:   wj
 * Date:     2020/4/15 22:06
 * Description: 关于我
 */
@RestController
@RequestMapping("/about")
public class AboutController {
    @Autowired
    AboutService aboutService;

    /**
     * 保存
     * @param about
     * @return
     */
    @PostMapping("/save")
    public Result<Object> save(@RequestBody About about){
        aboutService.save(about);
        return new Result<>("添加成功");
    }

    /**
     * 根据 id 删除
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public Result<Object> delete(@PathVariable String id){
        aboutService.delete(id);
        return new Result<Object>("删除成功");
    }

    /**
     * 更新
     * @param about
     * @return
     */
    @PutMapping("/update")
    public Result<Object> update(@RequestBody About about){
        aboutService.update(about);
        return new Result<Object>("更新成功");
    }

    /**
     * 根据id 查询
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public Result<About> getById(@PathVariable String id){

        return new Result<About>(aboutService.getById(id));
    }

}
